import json

import requests
from requests.auth import HTTPBasicAuth

# url = 'http://127.0.0.1:8000/admin/'
# # 默认可以重定向 allow_redirects=True
# # 所以返回的是重定向后的登录页面
# response = requests.get(url,allow_redirects=False)
#
# print(response.status_code)
# print(response.headers.get('location'))
#
#
# location = response.headers.get('location')
# location = f'http://127.0.0.1:8000{location}'
# response = requests.get(location)
# print(response.status_code)
# print(response.text)


url = 'http://127.0.0.1:8000/admin/'

response = requests.get(url,auth=HTTPBasicAuth('admin', '123456'))
print(response.status_code)
print(response.text)



